home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
MAKEITEZ.PRG
< prev
next >
Wrap
Text File
|
1993-05-23
|
7KB
|
217 lines
PROCEDURE MakeItEz
PARAMETERS pc_dbf
*----------------------------------------------------------------------------
* NAME
* MakeItEz - Takes a design DBF file created with SCR2DBF and gets it
* ready for code gen.
*
* DESCRIPTION
* MakeItEz will tie the dialog box controls together to make it easier
* for code generation. MakeItEz will do the following:
*
* - Convert the row and column coordinates to match the dialog
* box window. MakeItEz will place the new window row in Sys_flen,
* and the column in Length.
*
* - For edit controls, MakeItEz will place the right column of the
* field based on the template length into Decimals.
*
* - MakeItEz will alter the top row value for simple combo boxes
* ( "CS_" prefix ) and place the window offset coordinates for the
* resulting popup into the CS_ object's Descript field as a
* FROM ... TO ... clause. Decimals is Hieght, Length is Width.
*
* - MakeItEz will store the window definition for the dialog into
* the first box's Expression field. MakeItEz will store the window
* name into the first box's Filename field.
*
* PARAMETERS
* pc_dbf = name of the design DBF file with extension.
*
*----------------------------------------------------------------------------
PRIVATE lc_name, ln_winbotr, ln_winbotc, ln_rowoff, ln_coloff
lc_name = _Proper( pc_dbf )
*------------------------------------------------
*-- Get the box dimensions for the window offsets
*------------------------------------------------
LOCATE FOR value_type = "B" && Get the first box
ln_rowoff = row
ln_coloff = col
ln_winbotr = row + decimals - 1
ln_winbotc = col + length - 1
lc_windef = "FROM " + ;
STR( row, 2 ) + "," + STR( col, 2 ) + " TO " + ;
STR( ln_winbotr, 2 ) + "," + STR( ln_winbotc, 2)
REPLACE filename WITH lc_name, ;
expression WITH lc_windef
*-----------------------------------------------------------
*-- Pass over the edit controls, text, and titles to set the
*-- windows offset coordinates.
*-----------------------------------------------------------
GO TOP
SET FILTER TO
SCAN
*------------------
*-- Skip over boxes
*------------------
IF value_type = "B"
LOOP
ENDIF
*------------------------------
*-- Store the offset coordinate
*------------------------------
REPLACE sys_flen WITH row - ln_rowoff, ;
length WITH col - ln_coloff
IF value_type = "T"
REPLACE picfun WITH GetColor( display )
ENDIF
lc_prefix = LEFT( fieldname, 3 )
lc_suffix = RIGHT( TRIM( fieldname ), 2 )
*----------------------------------
*-- Check for a pick key assignment
*----------------------------------
ln_pick = AT( "~", template )
IF ln_pick > 0
lc_pick = SUBSTR( template, ln_pick + 1, 1 )
REPLACE pickkey WITH lc_pick
IF lc_prefix <> "BT_"
lc_text = LEFT( template, ln_pick - 1 )
lc_text = lc_text + TRIM( SUBSTR( template, ln_pick + 1 ) )
REPLACE descript WITH Delimit( lc_text )
ENDIF
ENDIF
*----------------------------------------------------
*-- Check for an edit control to establish click zone
*----------------------------------------------------
IF ( lc_suffix = "_1" .AND. lc_prefix $ "EF_,CS_,CD_,CL_,LB_,UD_" ) .OR. ;
lc_prefix = "BT_" .OR. ;
( lc_prefix $ "CK_,RB_,EF_" .AND. lc_suffix <> "_0" )
*-------------------------------------------------------
*-- Need to do some extra work for buttons to get length
*-------------------------------------------------------
IF lc_prefix = "BT_"
lc_temp = TRIM( template )
ln_lentemp = LEN( lc_temp )
IF ln_pick > 0
lc_text = LEFT( template, ln_pick - 1 )
lc_text = lc_text + TRIM( SUBSTR( template, ln_pick + 1 ) )
ELSE
lc_text = lc_temp
ENDIF
ln_fldlen = 0
ln = 1
DO WHILE ln <= ln_lentemp
IF SUBSTR( template, ln, 1 ) <> " "
ln_leadsp = ln - 1
IF "~" $ lc_temp
ln_fldlen = ln_lentemp + ln_leadsp - 1
ELSE
ln_fldlen = ln_lentemp + ln_leadsp
ENDIF
lc_text = lc_text + SPACE( ln_leadsp )
EXIT
ENDIF
ln = ln + 1
ENDDO
lc_text = lc_text
REPLACE descript WITH Delimit( lc_text )
ELSE
ln_fldlen = LEN( TRIM( template ) ) - IIF( ln_pick > 0, 1, 0 )
ENDIF
REPLACE decimals WITH col + ln_fldlen - 1
ENDIF
*-----------------------------------------------------
*-- While we are here, if this is a "CS_" object, then
*-- get the popup definition
*-----------------------------------------------------
IF lc_prefix $ "CS_,CL_,CD_,LB_,UD_"
lc_fldname = _Proper( TRIM( fieldname ) )
SKIP
IF value_type = "B"
IF .NOT. ( lc_prefix $ "LB_,UD_" )
REPLACE row WITH row + 1, ;
fieldname WITH UPPER( lc_fldname )
ELSE
REPLACE fieldname WITH UPPER( lc_fldname )
ENDIF
ln_top = row - ln_rowoff
ln_left = col - ln_coloff
IF lc_prefix = "UD_"
lc_popup = "DEFINE WINDOW " + lc_fldname + " FROM " + ;
STR( ln_top, 2 ) + "+nRowCls, " + STR( ln_left, 2 ) + "+nCol TO " + ;
STR( ln_top + decimals - 1, 2 ) + "+nRowCls, " + ;
STR( ln_left + length - 1, 2 ) + "+nCol"
ELSE
lc_popup = "DEFINE POPUP " + lc_fldname + " FROM " + ;
STR( ln_top, 2 ) + ", " + STR( ln_left, 2 ) + " TO " + ;
STR( ln_top + decimals - 1, 2 ) + ", " + ;
STR( ln_left + length - 1, 2 )
ENDIF
SKIP -1
REPLACE descript WITH lc_popup
ELSE
SKIP -1
ENDIF
ENDIF
ENDSCAN
RETURN
*-- EOP: MakeItEz WITH pc_dbf
FUNCTION Delimit
PARAMETERS pcString
*----------------------------------------------------------------------------
* DESCRIPTION
*
* PARAMETERS
* pcString =
*
*----------------------------------------------------------------------------
IF ASC( pcString ) < 32
IF LEN( pcString ) = 1
lcResult = "CHR( " + ASC( pcString ) + " )"
ELSE
IF LEN( pcString ) = 0
lcResult = ""
ELSE
lcResult = "REPLICATE( CHR( " + ASC( pcString ) + " ), " + ;
STR( LEN( pcString ) ) + " )"
ENDIF
ENDIF
ELSE
cLeft= '"'
cRight = '"'
IF AT( '"', pcString ) > 0
IF AT( "'", pcString ) > 0
cLeft = "["
cRight = "]"
ELSE
cLeft = "'"
cRight = "'"
ENDIF
ENDIF
lcResult = cLeft + pcString + cRight
ENDIF
RETURN( lcResult )
*-- EOF: Delimit( pcString )